﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- Fill Brushes -->

    <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
    <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />
    <SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />
    <SolidColorBrush x:Key="GlyphBrush" Color="#444" />
    <SolidColorBrush x:Key="hoverBrush" Color="LightGoldenrodYellow" />
    <SolidColorBrush x:Key="pressedBrush" Color="Goldenrod" />
    <!--toggle button template-->

    <ControlTemplate x:Key="ExpanderToggleButton" TargetType="ToggleButton">
        <Border Name="Border" Padding="2" Background="Transparent">
            <Path Name="Arrow" Fill="{StaticResource GlyphBrush}"
      HorizontalAlignment="Center" VerticalAlignment="Center"
      Data="M 0 0 L 4 4 L 8 0 Z"/>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="ToggleButton.IsMouseOver" Value="true">
                <Setter TargetName="Border" Property="Background"
              Value="{StaticResource hoverBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
                <Setter TargetName="Border" Property="Background"
              Value="{StaticResource pressedBrush}" />
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="Arrow" Property="Data"
              Value="M 0 4 L 4 0 L 8 4 Z" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="Border" Property="Background"
              Value="{StaticResource DisabledBackgroundBrush}" />
                <Setter TargetName="Border" Property="BorderBrush"
              Value="{StaticResource DisabledBorderBrush}" />
                <Setter Property="Foreground"
              Value="{StaticResource DisabledForegroundBrush}"/>
                <Setter TargetName="Arrow" Property="Fill"
              Value="{StaticResource DisabledForegroundBrush}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>


    <Style TargetType="{x:Type Expander}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Name="ContentRow" Height="0"/>
                        </Grid.RowDefinitions>
                        <Border Name="Border" Grid.Row="0" Background="#446666FF"
                                BorderBrush="#AA3333FF" BorderThickness="1"
                                >
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <ToggleButton VerticalAlignment="Center"
                IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,
                RelativeSource={RelativeSource TemplatedParent}}"
                OverridesDefaultStyle="True" 
                Template="{StaticResource ExpanderToggleButton}" />
                                <ContentPresenter Grid.Column="1" ContentSource="Header" 
                                                  RecognizesAccessKey="True" />
                            </Grid>
                        </Border>

                        <Border Name="Content" Grid.Row="1">
                            <ContentPresenter Margin="1" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter TargetName="ContentRow" Property="Height"
                    Value="{Binding ElementName=Content,Path=DesiredHeight}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Background"
                    Value="{StaticResource DisabledBackgroundBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush"
                    Value="{StaticResource DisabledBorderBrush}" />
                            <Setter Property="Foreground"
                    Value="{StaticResource DisabledForegroundBrush}"/>
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


</ResourceDictionary>